<%@ page language="java" import="recommenRatings.domain.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">


<%@page import="java.util.LinkedList"%><html>
<head>
<title>RecommenRatings - Buzon Entrada</title>
</head>
<body>
Perfil
<a href="FrontController?res=messages.jsp">Mensajes</a>
<a href="FrontController?res=searchUser.jsp">Usuarios</a> 
Fotos
<a href="FrontController?res=searchPlace.jsp">Lugares</a> 
Salir
<br/>
<br/>
<%	String currentUser = (String) session.getAttribute("session.user"); 
	String id = (request.getParameter("id"));
	if (id!=null){
		new MessageManager(currentUser).markAsRead(id);
		}%>  
<%MessageManager msgMngr = new MessageManager(currentUser); %>

<table summary ="Tus Mensajes" cellSpacing="1" cellPadding="6" width="770" align="center" border="0">
	<tr valign ="middle" align="center">
		<td  colspan="6"><b>MENSAJES</b></td>
	</tr>
	<tr valign ="middle" align="center" id="cabecera">
		<td><b><u>De:</u></b></td><td><b><u>Asunto</u></b></td><td><b><u>Mensaje</u></b></td> <td><b><u>Fecha</u></b></td><td><b><u>Leido</u></b></td><td><b><u>Borrar</u></b></td>
	</tr>
	
	
<%	UserManager um = new UserManager();
    for (Message m:msgMngr.getMessages()){
    	User u = um.userbyPOID(m.getSender());
    	String s = u.getName() +" "+u.getSurname();
    	
%>
			<tr align="center" id="productos">
				<td><%=s %></td>
				<td><%=m.getSubject()%> </td>
				<td><%=m.getText()%></td>
				<td><%=m.getDate()%></td>
				<td><%if (m.isRead()){%>
					<img src="img/tick.gif "width="35px" height="35px"></img>
				<% }else{%><a href="FrontController?res=readmsg.jsp?id=<%=m.getID() %>"> <img src="img/book.gif "width="35px" height="35px" ></img></a><%} %>
				</td>
				<td><a href="FrontController?res=deletemsg.jsp?id=<%=m.getID() %>"><img src="img/delete.gif" "width="35px" height="35px"></img></a>
				</td>
			</tr>
<%
		}
%>
</table>
    

</body>
</html>